import 'package:animations/animations.dart';
import 'package:flutter/material.dart';

class OpenContainerPage extends StatefulWidget {
  const OpenContainerPage({super.key});

  @override
  _OpenContainerPageState createState() => _OpenContainerPageState();
}

class _OpenContainerPageState extends State<OpenContainerPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('模板'),
      ),
      body: Center(
        // 使用open container 做详情页需要注意参数传入的问题，如果banner跳转进入的话，是通过getx路由进入的，所以可能会取不到参数的值
          child: OpenContainer(
            transitionDuration: const Duration(milliseconds: 500),
            // 打开状态
            openBuilder: (BuildContext context, VoidCallback _) {
              return const SecondPage();
            },
            // 闭合状态
            closedBuilder: (BuildContext context, VoidCallback openContainer) {
              return GestureDetector(
                onTap: openContainer,
                child: Container(
                  width: 200,
                  height: 200,
                  color: Colors.blue,
                  child: const Center(
                    child: Text(
                      'Tap to Open',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 20,
                      ),
                    ),
                  ),
                ),
              );
            },
          ),
      ),
    );
  }
}


class SecondPage extends StatefulWidget {
  const SecondPage({super.key});

  @override
  State<SecondPage> createState() => _SecondPageState();
}

class _SecondPageState extends State<SecondPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(appBar: AppBar(title:Text( '第二个页面'),
    ),
      body: Column(children: [],),
    );
  }
}
